﻿/*-------------------------------------------------------------------------
* 命名空间: WaferSelectV3.Common/GlobalValues
* 类       名: GlobalValues
* 功      能:  一些全局变量,主要是一些全局会用到的检测类型或者是检测规则类
* 时      间:  2024/5/6 21:16:22
* 版      本:  V1.0
* 作      者:  Fioman
* 格      言:  Talk is cheap,show me the code ^_^
*-------------------------------------------------------------------------*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WaferSelectV3.DAL.DataEntity;
using WaferSelectV3.Models;

namespace WaferSelectV3.Common
{
    public class GlobalValues
    {
        // 默认当前的登录者的信息
        public static UserEntity CurrentLoginUser = new UserEntity()
        {
            UserName = "Guest",
            Password = "123456",
            CreateBy = "System",
            CreateTime = DateTimeHelper.GetTimeNowForSql(),
            LastLoginTime = DateTimeHelper.GetTimeNowForSql(),
            Role = (int)RoleType.操作员,
        };

        /// <summary>
        /// 当前作业的晶棒编号
        /// </summary>
        public static string CurrentCrystalName = string.Empty;

        //  自定义的等级检测除了工单中的检测类型的其他类型
        public static Dictionary<int, string> DetectedTypeNamesDefineSelf = new Dictionary<int, string>()
        {
            //{30,"无等级直流" },
            {31,"缺数直流" },
            {32,"直流"},
            {33,"遮挡报警" },
            {34,"错位报警" },
            {35,"PLC通讯异常" },
            {36,"3D工位误触发"},
            {37,"3D数据错乱" },
            {38,"全部汇总" }, // 这里改变的时候,注意CrystalLevelCountModel中的赋值也要改变一下
            {39,"正常分选汇总"}
        };

        // 视觉自定义异常,用来归类的时候往汇总表里面写入.
        public static Dictionary<int, string> VisionErrorWithWaferId = new Dictionary<int, string>();

        /// <summary>
        /// 所有的检测等级和对应的检测类型描述,[Key,Value]-> [等级值,等级描述]
        /// </summary>
        public static Dictionary<int, string> DetectedTypeNamesTotal = new Dictionary<int, string>();

        // 客户一共开启了多少个正常检测等级,默认是15个. 程序里面是要可以计算的.
        public static int NormalDetectedTotalCounts = 15;

        /// <summary>
        /// 上一块电阻率的流水号
        /// </summary>
        public static int LastResistivityId = 0;
        /// <summary>
        /// 电阻率流水号队列,电阻率的值和流水号要对应上
        /// </summary>
        public static Queue<int> WaferIdQueue = new Queue<int>();
        /// <summary>
        /// 是否固定料盒,测试料盒的时候使用
        /// </summary>
        public static bool IsFixedBox = true;
        /// <summary>
        /// 如果是固定料盒,程序启动的时候的默认入选料盒为1
        /// </summary>
        public static int boxInto = 1;

        ///// <summary>
        ///// 主要是来记录时间更新时间(用电阻率和隐裂工位作为标准) 然后如果超过了4秒,就去汇总. 如果汇总的时候数据有缺失,就报缺数直流.
        ///// </summary>
        public static Dictionary<int, DateTime> WaferIdDateSummary = new Dictionary<int, DateTime>();
        // 已经屏蔽的检测模块
        public static List<string> ShieldModules = new List<string>();
        /// <summary>
        ///  流水号绑定它对应的检测等级.里面的那个字典表示的是,检测项,检测等级. 这样后面也好排查.但是这里后面跟int不行了,这里要筛选出来公共等级的.
        /// </summary>
        public static Dictionary<int, Dictionary<string, List<int>>> WaferIdLevelDictionary = new Dictionary<int, Dictionary<string, List<int>>>();
        // 补偿值列表所有工位的,用变量名对应的K和B的值
        public static Dictionary<string, double[]> VisionOffsetMap = new Dictionary<string, double[]>();
        /// <summary>
        /// 流水号绑定的PC端的消息.用来判断在分选的时候,这些消息是否都已经收到,主要用来检测是否有消息缺失.
        /// </summary>
        public static Dictionary<int, List<string>> WaferIdHeaderClientMap = new Dictionary<int, List<string>>();
        /// <summary>
        /// 流水号和电阻率的结果值绑定的结果的字典,其中电阻率的值(最大值,最小值,平均值,PN结果)
        /// </summary>
        public static Dictionary<int, Tuple<double, double, double, string>> WaferIdResistivityValMap = new Dictionary<int, Tuple<double, double, double, string>>();

        // 用来保存流水号对应的数据,就是前面这些数据,比如入选料盒啊,分选类型啊,晶棒编号啊这些消息
        public static Dictionary<int, string[]> WaferIdDataComman = new Dictionary<int, string[]>();
        // 用来保存3D工位数据第一部分
        public static Dictionary<int, string[]> WaferIdData3d01 = new Dictionary<int, string[]>();
        // 用来保存3D工位数据第二部分
        public static Dictionary<int, string[]> WaferIdData3D02 = new Dictionary<int, string[]>();

        // 用来保存电阻率工位数据
        public static Dictionary<int, string[]> WaferIdDataResistivity = new Dictionary<int, string[]>();

        // 用来保存尺寸工位数据
        public static Dictionary<int, string[]> WaferIdDataSize = new Dictionary<int, string[]>();

        // 用来保存崩边工位数据
        public static Dictionary<int, string[]> WaferIdDataEdgeBreak = new Dictionary<int, string[]>();

        // 用来保存脏污工位的数据
        public static Dictionary<int, string[]> WaferIdDataSmudge = new Dictionary<int, string[]>();

        // 用来保存隐裂工位的数据
        public static Dictionary<int, string[]> WaferIdDataSubfissure = new Dictionary<int, string[]>();

        /// <summary>
        /// 检测等级和料盒对应关系.
        /// 一个检测等级可能对应多个料盒, 多个检测等级也可能是一个料盒.`    
        /// </summary>
        public static Dictionary<int, List<int>> LevelBoxMap = new Dictionary<int, List<int>>();
    }
}
